Add polyfills for Queue<T>.TryDequeue(...) and Queue<T>.TryPeek(...)#48
Add polyfills for Queue<T>.TryDequeue(...) and Queue<T>.TryPeek(...)#48
Queue<T>.TryDequeue(...) and Queue<T>.TryPeek(...)#48Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds polyfill implementations for Queue<T>.TryDequeue(out T?) and Queue<T>.TryPeek(out T?) methods, which were introduced in .NET Core 2.0. These polyfills enable older frameworks (.NET Framework, .NET Core 1.x, and .NET Standard < 2.1) to use these convenient "Try" pattern methods that safely attempt to dequeue or peek at queue elements without throwing exceptions when the queue is empty.
Key changes:
- Added polyfill implementations for
Queue<T>.TryDequeueandQueue<T>.TryPeekinPolyShim/NetCore20/Queue.cs - Added comprehensive unit tests covering both success and failure scenarios
- Updated documentation to reflect the two new method signatures
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| PolyShim/NetCore20/Queue.cs | Implements polyfills for TryDequeue and TryPeek methods on Queue<T> using check-then-act pattern with Count property |
| PolyShim.Tests/NetCore20/QueueTests.cs | Adds comprehensive test coverage for both methods including empty queue, multiple elements, and peek-after-dequeue scenarios |
| PolyShim/Signatures.md | Updates total signature counts and adds documentation entries for the two new Queue methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #48 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.